<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Router Push</title>
    <script src="../vue.js"></script>
    <script src="../vue-router.js"></script>
</head>
<body>
   <div id="app">
        <button @click="goStart">跳转</button>
        <button @click="goBack">后退</button>
        <router-view></router-view>
   </div> 

   <script>
       var user={
           template:'<p>用户名：{{this.$route.params.name}}</p>'
       }

       var router=new VueRouter({
           routes:[
               {path:'/user',name:'user',component:user}
           ]
       })

        var vm = new Vue({
            el:"#app",
            methods:{
                goStart(){
                    this.$router.push({name:'user',params:{name:'admin'}})
                },
                goBack(){
                    this.$router.go(-1)
                }
            },
            router
        })

   </script>
</body>
</html>